local nailuo = fk.CreateSkill{
    name = "ym1__nailuo",
}
Fk:loadTranslationTable{
    ["ym1__nailuo"] = "奈落",
    ["ym1__lunciskill"] = "<b>轮次技</b>：即“每轮限一次”的简称，指“于每个轮次中限发动一次”。<br>为标识技能发动频率的词语，不属于技能标签。",
    [":ym1__nailuo"] = "<a href='ym1__lunciskill'>轮次技</a>，当你使用无目标角色牌时，你可以摸至至多五张牌，其后等量张牌被使用时，场上角色技能失效至此牌结算完成。",
    ["#ym1__nailuo-draw"] = "你可以发动 奈落，选择摸牌的数量",
    ["ym1__nailuo_draw1"] = "摸至一张牌",
    ["ym1__nailuo_draw2"] = "摸至两张牌",
    ["ym1__nailuo_draw3"] = "摸至三张牌",
    ["ym1__nailuo_draw4"] = "摸至四张牌",
    ["ym1__nailuo_draw5"] = "摸至五张牌",
    ["@ym1__nailuo"] = "奈落",
    ["@@ym1__nailuo-turn"] = "奈落 技能失效",

    ["$ym1__nailuo1"] = "此生如朝露，身名俱灭。",
    ["$ym1__nailuo2"] = "忘川无波澜，引渡徘徊。",
}
nailuo:addEffect(fk.CardUsing,{
    anim_type = "drawcard",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(nailuo.name) and target == player and ( data.tos == nil or #data.tos == 0) and player:usedSkillTimes(nailuo.name, Player.HistoryRound) == 0
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local choices = {}
        for i = 1, 5, 1 do
            table.insert(choices, "ym1__nailuo_draw" .. tostring(i))
        end
        table.insert(choices, "Cancel")
        local choice = room:askToChoice(player,{
            choices = choices,
            skill_name = nailuo.name,
            prompt = "#ym1__nailuo-draw",
        })
        if choice ~= "Cancel" then
            self.cost_data = choice
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local x = tonumber(string.sub(self.cost_data, 17, 17))
        room:setPlayerMark(player, "@ym1__nailuo", x)
        if player.general == "ym1__huangquan" then
            player.general = "ym1__huangquan2"
            room:setPlayerMark(player, "#ym1__huangquan_showGeneral", "ym1__huangquan2")
            room:broadcastProperty(player, "general")
        end
        if player:getHandcardNum() < x then
            room:drawCards(player, x - player:getHandcardNum(), nailuo.name)
        end
    end,
})
nailuo:addEffect(fk.CardUsing,{
    can_refresh = function(self, event, target, player, data)
        return player:getMark("@ym1__nailuo") > 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:removePlayerMark(player, "@ym1__nailuo")
        if player:getMark("@ym1__nailuo") == 0 then
            if player:getMark("#ym1__huangquan_showGeneral") == "ym1__huangquan2" then
                player.general = "ym1__huangquan"
                room:setPlayerMark(player, "#ym1__huangquan_showGeneral", "ym1__huangquan")
                room:broadcastProperty(player, "general")
            end
        end
        table.forEach(table.filter(room.alive_players, function(p)
            return p:getMark("@@ym1__nailuo-turn") == 0
        end), function(p)
            room:setPlayerMark(p, "@@ym1__nailuo-turn", 1)
        end)
        room.logic:getCurrentEvent():addCleaner(function ()
            table.forEach(room.alive_players, function(p)
                room:setPlayerMark(p, "@@ym1__nailuo-turn", 0)
            end)
        end)
    end,
})
nailuo:addEffect("invalidity",{
    invalidity_func = function(self, from, skill)
        return from:getMark("@@ym1__nailuo-turn") > 0
    end,
})
nailuo:addEffect(fk.GameFinished,{
    can_refresh = function (self, event, target, player, data)
        return player:getMark("#ym1__huangquan_showGeneral") == "ym1__huangquan2"
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        if player.general == "ym1__huangquan2" then
            player.general = "ym1__huangquan"
            room:setPlayerMark(player, "#ym1__huangquan_showGeneral", "ym1__huangquan")
            room:broadcastProperty(player, "general")
        end
    end,
})
nailuo:addAcquireEffect(function (self, player, is_start)
    player:chat("为寻索，为顿悟，为存在…人行于命途之上。")
    player.room:broadcastPlaySound("./packages/ym_Al/audio/show/ym1__huangquan")
end)
return nailuo